package com.zygh.policeasset.controller;

import com.zygh.policeasset.component.CommonResult;
import com.zygh.policeasset.pojo.Role;
import com.zygh.policeasset.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping({"/role"})
@Api(tags = {"角色管理模块"})
@RestController
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/controller/RoleController.class */
public class RoleController {
    @Autowired
    private RoleService roleService;

    @RequestMapping(value = {"/findAllRole"}, method = {RequestMethod.GET})
    @ApiOperation("查询所有角色")
    public Object findAllRole(int pageNum, int pageSize) {
        return this.roleService.findAllRole(pageNum, pageSize);
    }

    @RequestMapping(value = {"/addRole"}, method = {RequestMethod.POST})
    @ApiOperation("添加角色")
    public Object addRole(@RequestBody Role role) {
        if (this.roleService.addRole(role).intValue() > 0) {
            return new CommonResult().success();
        }
        return new CommonResult().validateFailed("添加角色错误");
    }

    @RequestMapping(value = {"/updateRole"}, method = {RequestMethod.POST})
    @ApiOperation("修改角色")
    public Object updateRole(@RequestBody Role role) {
        if (this.roleService.updateRole(role).intValue() > 0) {
            return new CommonResult().success();
        }
        return new CommonResult().validateFailed("修改角色错误");
    }

    @RequestMapping(value = {"/deleteRole"}, method = {RequestMethod.POST})
    @ApiOperation("删除角色")
    public Object deleteRole(@RequestBody Role role) {
        if (this.roleService.deleteRole(role.getId()).intValue() > 0) {
            return new CommonResult().success();
        }
        return new CommonResult().validateFailed("删除角色错误");
    }
}